<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/index.css">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>

<body>
    <div class="content">
        <div id="list">
            <img src="images/01.png" alt="">
            <img src="images/02.png" alt="">
            <img src="images/03.png" alt="">
            <img src="images/04.png" alt="">
            <img src="images/05.png" alt="">
        </div>

        <button id="prev"></button>
        <button id="next"></button>
        <div id="btns">
            <span class="current"></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
        </div>
    </div>
</body>
<script>
    var index = 0;
    $("#next").click(function(){
        index++;
        if(index>$('#list img').length-1){
            index = 0;
        }
        imgToggle(index)
    })
    $("#prev").click(function(){
        index--;
        if(index<0){
            index = $('#list img').length-1;
        }
        imgToggle(index)
    })
    $('#btns span').click(function(){
         index = $(this).index()
         imgToggle(index)
    })
    function imgToggle(index){
        $('#btns span').eq(index).addClass('current').siblings().removeClass('current');
        $("#list img").eq(index).show().siblings().hide();
    }

    function slide(){
        setInterval(function(){
            $("#next").click()
        },2000)
    }
    slide()
</script>
</html>